package com.mepo.cheer.client.pages;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class HomePage extends Composite {

	private static final String NEWS_STRING = "Practice January 4th has been cancelled due to weather.<br/><br/><br/>" +
			"Congratulations to Competition Squad who earned 5th place at State Cheerleading!<br/><br/><br/>" +
			"Fall 2012 tryouts are May 17th, 2012 in the elementry gym.";
	
	public HomePage() {
		HorizontalPanel content = new HorizontalPanel();
		content.setSize("100%", "100%");
		content.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		
		Image image = new Image("images/cheer-group.jpg");
		image.addStyleName("home-img");
		content.add(image);
		
		VerticalPanel newsPanel = new VerticalPanel();
		newsPanel.setWidth("300px");
		newsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		
		Label header = new Label("Cheer News");
		header.addStyleName("home-header");
		newsPanel.add(header);
		
		HTML news = new HTML(NEWS_STRING);
		news.addStyleName("home-news");
		newsPanel.add(news);
		
		Button scheduleButton = new Button();
		scheduleButton.setHTML("Go Bulldogs!<br/><span style='font-size:16px;'>Game Schedule</span>");
		scheduleButton.addStyleName("home-button");
		newsPanel.add(scheduleButton);
		
		//create popup panel
		final PopupPanel popup = new PopupPanel(true, true);
		VerticalPanel popContents = new VerticalPanel(); 
		HTML iFrameCalendar = new HTML("<iframe id=\"1889573064\" src=\"https://www.google.com/calendar/embed?src=cassieschill@gmail.com&amp;color=%23668CD9&amp;mode=MONTH&amp;showTitle=0&amp;showNav=1&amp;showDate=1&amp;showTabs=1&amp;showCalendars=0&amp;hl=en\" title=\"Cheerleading\" width=\"800\" height=\"500\" frameborder=\"0\" scrolling=\"no\"></iframe>");
		popContents.add(iFrameCalendar);
		Button closeButton = new Button("Close", new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				popup.hide();
			}
		});
		popContents.add(closeButton);
		popContents.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_RIGHT);
		popup.add(popContents);
		
		scheduleButton.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				popup.center();
			}
		});
		
		
		content.add(newsPanel);
		content.setCellHorizontalAlignment(newsPanel, (HasHorizontalAlignment.ALIGN_LEFT));
		initWidget(content);
	}
}
